"""
selenium使用js代码滑动滚动条
"""
import time

from selenium import webdriver

driver = webdriver.Chrome()
driver.get("https://news.baidu.com/")
driver.maximize_window()
driver.execute_script('window.scrollTo(0,500)')  # 向下滑动500像素
time.sleep(3)
driver.execute_script('window.scrollTo(0,0)')  # 滑动到顶部
time.sleep(3)
driver.execute_script('window.scrollTo(0,document.body.scrollHeight)')  # 滑动到底部
time.sleep(3)
driver.close()
